473,406 Members | 2,707 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Structure of the code (files, dir's, namespaces, makefiles)

db
Hey group

I'm rewriting a small program called lockdown and need a little help
structuring the code. In the past I didn't use nested namespaces and I
placed all my files in one directory. This time I tried to change this,
but ran into some beginner problems. I have:
namespace lockdown;
namespace lockdown::io;
namespace lockdown::io::in;
namespace lockdown::io::out;
namespace lockdown::modifiers;
I've made a dir to every namepace, so I have:
io
io/in
io/out
modifiers
btw I'm using FreeBSD and gcc.
The lockdown::io::in namespace is defined in io/in.hpp, but first
mentioned in io.hpp. All the code (classed and functions) for that
namespace is placed in the io/in dir.
Let's look at io.hpp:
#ifndef LOCKDOWN_IO_HPP
#define LOCKDOWN_IO_HPP
#include "lockdown.hpp" //Here lockdown::io is mentioned for the first time
namespace lockdown { namespace io {
//nested namespace where the definition is in the dir
lockdown/io/out.hpp namespace out {}
namespace in {}
class IOException;
//Class definition is in lockdown/io/File.hpp
class File;
}}

Is that the right way of doing it? Or should I #include the definition
of the namespaces and classes/functions?

Next question is about Makefile's. In every dir I have a Makefile that
compiles every file and dir in that dir and makes a "dir".o file and
place it in the above dir. Let's take a look at some Makefile's:
The Makefile in lockdown/io/out
CXX ?= g++
CFLAGS += -Wall

all: Output.o
cp Output.o ../out.o

Output.o: Output.hpp
$(CXX) $(CFLAGS) -c Output.cpp -o $@

clean:
rm -f *.o

In lockdown/io/Makefile I have:
CXX ?= g++
CFLAGS += -Wall

all: out.o File.o
$(CXX) $(CFLAGS) -shared File.o out.o -o ../io.o

out.o:
make -C out all

File.o: File.hpp
$(CXX) $(CFLAGS) -c File.cpp -o $@

clean:
rm -f *.o
make -C out clean

Is that how it is done? The problem here is that I don't want to use
shared objects, but I can't see how to avoid it (don't want to include
very .o file in the entire project then linking the final lockdown
executable).

br
db

Btw: I can send you the code if you wanna see it...just don't download
it from lockdown.trunet.dk as it is an old version.
Jul 22 '05 #1
2 1928
db wrote:
Hey group

I'm rewriting a small program called lockdown and need a little help
structuring the code. In the past I didn't use nested namespaces and I
placed all my files in one directory. This time I tried to change this,
but ran into some beginner problems. I have:
namespace lockdown;
namespace lockdown::io;
namespace lockdown::io::in;
namespace lockdown::io::out;
namespace lockdown::modifiers;
I've made a dir to every namepace, so I have:


Whoa! Slow down there. Why do you think you need all these namespaces
with separate directories for each for this small program? If you can't
answer this question then you have gone too far.
Jul 22 '05 #2
db
On Tue, 13 Apr 2004 08:04:30 -0500
Bill Seurer <se****@us.ibm.com> wrote:
namespace lockdown;
namespace lockdown::io;
namespace lockdown::io::in;
namespace lockdown::io::out;
namespace lockdown::modifiers;
I've made a dir to every namepace, so I have:


Whoa! Slow down there. Why do you think you need all these
namespaces with separate directories for each for this small program?
If you can't answer this question then you have gone too far.


Since it is much a small program and I'll end up having just one huge
executable file, I could survice with just one namespace and all files
in one dir. I know it is overhead , but surly this doesn't matter?
I find the above structering of the code logical and I find it naturally
to relect this in the psysical world (with files and dir's)!?!?!

br
db
Jul 22 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Vagif Abilov | last post by:
We decided to adopt .NET coding guidelines posted by Brad Abrams from Microsoft: http://blogs.msdn.com/brada/archive/2005/01/26/361369.aspx Here is what Brad (and AFAIK Microsoft) suggests...
1
by: Anil Kumar Narayanan | last post by:
This is the DIR command of MS-DOS and works for a floppy drive media.. it retrieves all the files whether deleted or not from the floppy drive.. but i was unsuccessful in getting the Date and Time...
2
by: db | last post by:
Hey group I'm rewriting a small program called lockdown and need a little help structuring the code. In the past I didn't use nested namespaces and I placed all my files in one directory. This...
4
by: Mikkel christensen | last post by:
Hi there I wonder if any of you could point me in a direction where I can find some usefull information about coding standarts. I have some generel experiense in programming but I lack many...
4
by: shane | last post by:
From searching around, Ive seen this question asked numerous times, but havent seen a usable answer unfortuantly. What Im trying to do is something I would have thought would be quite common,...
1
by: LenS | last post by:
If this is the wrong place to post this, please advise better place. Otherwise, I have created the following python program and it works. Running on XP. I think I am now at that stage of learning...
8
by: James Owens | last post by:
I'm a relative newbie, interested in storing the information from several server directories and subdirectories in XML so that I can present it selectively using XSL (all files updated today or...
6
by: dave | last post by:
I really have 2 questions regarding the following xml snippet. The xml is a directory representation. <?xml version="1.0" standalone="yes"?> <FileSystem> <Row> <ID>1</ID> <Name>Root</Name>...
4
by: Sergei Minayev | last post by:
Hi All! Can you please help me with the following problem: I need to store a copy of local folders structure in MySQL database. I have chosen the following table structure for that:...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.