목록분류 전체보기 (277)
ecsimsw
object factory - Design pattern to instance variety type's object. - 사용 이유 자료형에 대한 정보는 있지만, C++ 에서 표현 가능한 형태가 아닌 경우 - 파일을 읽고, 객체를 생성하는 경우 - 인터넷 패킷을 받고, 객체를 생성하는 경우 객체 생성시 의무적으로 해야할 일이 있을 경우 simple example human* human_factory(char sex) { human* h = 0; switch (sex) { case 'M': h = new Man(); break; case 2: h = new Woman(); break; } return h; }
"CODE" ///"tensorflow/core/platform/file_system.h" class FileSystemRegistry { public: typedef std::function Factory; virtual ~FileSystemRegistry(); virtual Status Register(const string& scheme, Factory factory) = 0; virtual FileSystem* Lookup(const string& scheme) = 0; virtual Status GetRegisteredFileSystemSchemes( std::vector* schemes) = 0; }; /// tensorflow/core/framework/op_kernel.h namespace..
"CODE" ///op_kernel.cc :: Kernel registration struct KernelRegistration { KernelRegistration(const KernelDef& d, StringPiece c, kernel_factory::OpKernelRegistrar::Factory f) : def(d), kernel_class_name(std::string(c)), factory(f) {} const KernelDef def; const string kernel_class_name; const kernel_factory::OpKernelRegistrar::Factory factory; }; // This maps from 'op_type' + DeviceType to the set..
"CODE" ///// tensorflow/core/kernels/training_ops.cc #define REGISTER_KERNELS(T, Tindices) \ REGISTER_KERNEL_BUILDER(Name("SparseApplyProximalAdagrad") \ .Device(DEVICE_CPU) \ .TypeConstraint("T") \ .TypeConstraint("Tindices"), \ SparseApplyProximalAdagradOp); \ REGISTER_KERNEL_BUILDER(Name("ResourceSparseApplyProximalAdagrad") \ .Device(DEVICE_CPU) \ .TypeConstraint("T") \ .TypeConstraint("Tind..
std::initializer_list cppreference_ std::initializer_list Stackoverflow _The constructor initializer list and const variable initializer list className (parameter) : varName1(arg), varName2(arg) {}; - 위의 형식으로 생성자를 정의하는 것으로 생성과 동시에 멤버 변수를 초기화 하고, 이를 생성자 리스트라고 한다. #include using namespace std; class myclass { int integer; char character; public: myclass(): integer(10), character('A'){};// construc..
ctags / cscope - ctags와 cscope를 이용하여 코드를 분석하는 방법과 유용했던 팁을 정리하였다. ctags - tj 명령어 뒤에 원하는 태그 이름을 입력하는 것으로 해당 함수나 변수가 선언된 위치로 점프할 수 있다. :tj "tags" - 명령어를 이용하지 않고 원하는 함수나 변수 위에 커서를 두고 점프하고 이전으로 돌아갈 수 있다. ctrl + ] ctrl + t cscope - cs type option keyword로 실행한다. type은 add / find / help / kill / reset / show 가 있고, find(f)와 아래 옵션을 통해 키워드를 검색한다. cscope commands[f] g : find the definitions s : search this ..
scope resolution operator stackoverflow_ C++ : what is :: for? namespace - 복수개의 header를 사용할 때, header 안 멤버가 중복될 경우를 방지하기 위해 공간을 마련. 같은 이름의 함수 print가 A.h / B.h에서 정의된다고 가정할 때 아래와 같은 방식으로 혼란을 피한다. sol1) Scope resolution operator int main(void){ A::print(); B::print(); } sol2) namespace using namespace A; int main(void){ print(); B::print(); }
ctags / cscope - 리눅스에서 길고 복잡한 코드를 다룰때 유용한 유틸리티 두가지. ctags - 소스 코드의 태그(변수, 함수, 매크로 등의 선언 부분)들의 데이터 베이스 파일을 생성해 인덱스를 만들어 주어, 코드 분석 시 탐색할 수 있도록 하는 유틸리티이다. sudo apt-get install ctags - tags 파일을 생성하여 소스 코드의 태그를 데이터 베이스로 관리할 수 있다. ctags "Filename" ctags -R - 위 두 명령어처럼 ctags 다음에 파일 이름을 명시하는 것으로 해당 파일만 tags 파일을 만들거나, 아래 ctags -R처럼 현재 디렉토리의 모든 파일/ 하위 디렉토리의 모든 파일을 대상으로 tags 파일을 만들 수 있다. - vi 에디터에 tags 파일 ..